﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using PPIDesktopClient.General;
using PPIDesktopClient.Entities;
using PPIProxy;
using VMind.Global;
using PPIMobileInterface;

namespace PPIDesktopClient.Logic
{
    public class LXMissionStructures_PoleClass
    {
        public static List<EXMissionStructures_PoleClass> SelectAllIdName(DataTable dt)
        {
            List<EXMissionStructures_PoleClass> _XMissionStructures_PoleClassList = new List<EXMissionStructures_PoleClass>();
            EXMissionStructures_PoleClass _XMissionStructures_PoleClass;

            foreach (DataRow dr in dt.Rows)
            {
                _XMissionStructures_PoleClass = new EXMissionStructures_PoleClass(ConvertHelper.ToInt32(dr["XMissionStructures_PoleClassId"]), dr["Name"].ToString());
        		_XMissionStructures_PoleClassList.Add(_XMissionStructures_PoleClass); 
            }

            return _XMissionStructures_PoleClassList;
            
        }
        public static List<EXMissionStructures_PoleClass> SelectAllIdName()
        {
            ConfigReader _Reader = ConfigReader.GetInstance();
            DataTable dt = WXMissionStructures_PoleClass.SelectAllIdName(_Reader.GetConnectionString()).Tables[0];
            return SelectAllIdName(dt);

        }

        public static void InsertClass(string connectionString)
        {

            StringBuilder _query = new StringBuilder();
            List<EXMissionStructures_PoleClass> _classes = LXMissionStructures_PoleClass.SelectAllIdName();
            foreach (EXMissionStructures_PoleClass c in _classes)
            {
                _query.AppendLine("insert into tb_Lookups (LookupValue,LookupText,LookupTypeFk) values (" + c.XMissionStructures_PoleClassId + ",'" + c.Name + "','Classes')");
            }
            Utils.InsertClasses(connectionString, _query.ToString());
        }
    }
}
